<?php
namespace app\designer\library\database;

use app\designer\library\Database;

class mssql extends Database{
    public function getCreateTableSQL(string $table){
        $data = $this->db->query("SELECT * FROM sysobjects WHERE xtype='U' AND name='".$table."'");
        if (!$data){
            return '';
        }else{
            return $data['Create Table'];
        }
    }

    public function getTableList(){
        $data = $this->db->query("SELECT  [name] as [table] FROM sysobjects WHERE xtype='U'");
        if (!$data){
            return [];
        }else{
            return $data;
        }
    }

    public function getTableField(string $table){
        $data = $this->db->query("SELECT  [name] as [field] FROM syscolumns WHERE id=OBJECT_ID('".$table."')");
        $re = [];
        if ($data){
            foreach ($data as $k=>$v){
                $re[] = $v['field'];
            }
        }

        return $re;
    
    }


    public function getTableComment(string $table){
        return '';
    }
}